import React, { Component } from 'react'
import { Button } from 'antd';
import axios from 'axios'
export default class Home extends Component {
  render() {
    // 获取数据
    const getList=()=>{
      axios.get('http://localhost:8000/posts').then(res=>{
        console.log(res)
      })
    }
    // 增加数据
    const pushList=()=>{
      axios.post('http://localhost:8000/posts',{
        title:"新的",
        author:"刘昊然"
      })
    }
    // 修改put
    const putList=()=>{
      axios.put('http://localhost:8000/posts/1',{
        title:"11111-修改",

      }).then(res=>{
        console.log(res)
      })
    }
    return (
      <div>
        Home
          <Button type="primary" onClick={()=>{
            getList()
          }}>Button</Button>
          <Button type="primary" onClick={()=>{
            pushList()
          }}>add</Button>
          <Button type="primary" onClick={()=>{
            putList()
          }}>put</Button>
      </div>
    )
  }
}
